#include <iostream>

// 接口类
class Interface {
public:
    virtual void doSomething() = 0; // 纯虚函数，定义接口
    virtual ~Interface() {} // 虚析构函数
};

// 实现类A
class ImplementationA : public Interface {
public:
    void doSomething() override {
        // 具体的实现
        std::cout  << "ImplementationA" << std::endl;
        
    }
};

// 实现类B
class ImplementationB : public Interface {
public:
    void doSomething() override {
        // 不同的实现
        std::cout  << "ImplementationB" << std::endl;

    }
};

int main() {
    Interface* ptrA = new ImplementationA();
    Interface* ptrB = new ImplementationB();

    ptrA->doSomething(); // 调用ImplementationA的实现
    ptrB->doSomething(); // 调用ImplementationB的实现

    delete ptrA;
    delete ptrB;

    return 0;
}
